package edu.langnan.xiaoli.controller.business;

import edu.langnan.xiaoli.base.AjaxResult;
import edu.langnan.xiaoli.base.controller.BaseController;
import edu.langnan.xiaoli.config.security.TokenService;
import edu.langnan.xiaoli.core.dto.VolunteerDTO;
import edu.langnan.xiaoli.core.page.TableDataInfo;
import edu.langnan.xiaoli.service.VolunteerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author cql
 */
@RestController
@RequestMapping("volunteer")
public class VolunteerController extends BaseController {

    @Autowired
    private TokenService tokenService;

    @Autowired
    private VolunteerService volunteerService;

    /**
     * 分页获取志愿者活动列表
     *
     * @return
     */
    @GetMapping("list")
    public TableDataInfo volunteerList(HttpServletRequest request) {
        Integer stuId = tokenService.getLoginUser(request).getId();
        startPage();
        List<VolunteerDTO> result = volunteerService.studentOfVolunteerList(stuId);
        return getDataTable(result);
    }

    /**
     * 志愿活动报名
     *
     * @param vid
     * @param request
     * @return
     */
    @PostMapping("signup")
    public AjaxResult signUpActivity(Integer vid, HttpServletRequest request) {


        return AjaxResult.success();
    }

}
